924A - Mystical Mosaic - CodeForces Solution


greedy implementation *1300

Please click on ads to support us..

C++ Code:

#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<vector<bool>> a(n, vector<bool>(m, false));

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            char v;
            cin >> v;

            a[i][j] = v == '#';
        }

    for (int i = 0; i < n - 1; i++)
        for (int j = i + 1; j < n; j++)
        {
            bool noIntersection = true;
            bool equal = true;
            for (int k = 0; k < m; k++)
            {
                if (a[i][k] != a[j][k])
                    equal = false;
                if (a[i][k] && a[j][k])
                    noIntersection = false;
            }
            if (!equal && !noIntersection)
            {
                cout << "No\n";
                return 0;
            }
        }

    cout << "Yes\n";

    return 0;
}


Comments

Submit
0 Comments
More Questions

279A - Point on Spiral
1294D - MEX maximizing
447A - DZY Loves Hash
23B - Party
63D - Dividing Island
1203E - Boxers
1547F - Array Stabilization (GCD version)
358A - Dima and Continuous Line
1385C - Make It Good
651A - Joysticks
1474D - Cleaning
1588A - Two Arrays
816A - Karen and Morning
9D - How many trees
918B - Radio Station
15A - Cottage Village
1737B - Ela's Fitness and the Luxury Number
1425H - Huge Boxes of Animal Toys
1737A - Ela Sorting Books
768C - Jon Snow and his Favourite Number
1006C - Three Parts of the Array
81A - Plug-in
276C - Little Girl and Maximum Sum
1738D - Permutation Addicts
1348B - Phoenix and Beauty
186A - Comparing Strings
1281A - Suffix Three
1421C - Palindromifier
1443A - Kids Seating
963A - Alternating Sum